var MAIN = {
		init:function(){
			$('.tooltip-show').tooltip();
			/*$(window).scroll(function(e){
				var $menu = $('#page-menu');
				var cls = $menu.attr('class') + '';
				var scrollTop = parseInt($(this).scrollTop(), 10);
				var menuTop = parseInt($menu.offset().top, 10);
				var heightTopMenu = parseInt($('#menu-top-page').height(), 10);
				if(cls.indexOf('fixed')>=0){
					menuTop = parseInt( $('#page-body').offset().top, 10) -  parseInt($menu.height(), 10) ;
				}
				
				//alert(scrollTop + ' - ' + menuTop + ' - ' + heightTopMenu);
				if(scrollTop >= menuTop - heightTopMenu){
					 if(cls.indexOf('fixed') < 0) {
						 $menu.addClass('fixed');
						 $('#pfloat').addClass('mt78');
					 }
				}else if (cls.indexOf('fixed')>=0){
					$menu.removeClass('fixed');
					$('#pfloat').removeClass('mt78');
				}
			});*/
			$('img.captcha').css('cursor','pointer').attr('title','click để thay đổi hình ảnh.').click(function(){
				var d = new Date();
				$(this).attr('src','/captcha?no='+d.getTime());
			});
			$('input.captcha').keydown(function(event) {
				// Allow: backspace, delete, tab, escape, and enter,  Ctrl+A, home, end, left, right
				if ( event.keyCode ==190 || event.keyCode == 110 ||  event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 || (event.keyCode == 65 && event.ctrlKey === true) || (event.keyCode >= 35 && event.keyCode <= 39)) {
					return;
				}
				else {
					// Ensure that it is a number and stop the keypress
					if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) {
						event.preventDefault(); 
					}
				}
			});
			$('div.advs').each(function(){
				var obj = $(this);
				$.ajax({
					type: "POST",
					url: '/advertise/getAdv',
					data: {
						'advPage': obj.attr('data-page'),
						'attr': obj.attr('data-attr'),
						'page': parseInt(obj.attr('data-page-num'),10),
						'limit': parseInt(obj.attr('data-limit'),10)
					},
					cache: false,
					success: function(data){
						obj.append(data);
					}
				});
			});
		},
		showAjaxLoader:function(){
			$('div#page-loading').show();
		},
		hideAjaxLoader: function(){
			$('div#page-loading').hide();
		}
}